package com.hp.service.impl;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hp.entity.Member;
import com.hp.mapper.MemberMapper;
import com.hp.service.MemberService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.ArrayList;
import java.util.List;

/**
 * @author hp
 */
@Service
public class MemberServiceImpl extends ServiceImpl<MemberMapper, Member> implements MemberService {


    @Override
    public List<Member> listAll() {
        return list();
    }

    @Override
    public List<Member> listByMemberId(String memberId) {
        LambdaQueryWrapper<Member> query = Wrappers.lambdaQuery();
        query.eq(Member::getMemberId, memberId);
        return list(query);
    }


    @Override
    @Transactional(rollbackFor = Exception.class)
    public void insert() {
        List<Member> applyList = new ArrayList<>();
        for (int i = 0; i < 10000; i++) {
            Member apply = new Member();
            apply.setMemberId(i);
            applyList.add(apply);
        }
        saveBatch(applyList);
    }

}
